import Packet from "../net/Packet"

// 随机名字返回
export default class AccountRandNameOk {
	/**
	 * @param name 名字
	 */
	public constructor(public name: string) { }

	public encode(): Packet {
		const packet = this._encode()
		packet.Encode(2060)
		return packet
	}

	public encodeMsg(): ByteBuffer {
		return this._encode().GetBuffer()
	}

	public static decode(packet: Packet): AccountRandNameOk {
		const name = packet.ReadString()
		return new AccountRandNameOk(name)
	}

	private _encode(): Packet {
		const packet = new Packet()
		packet.WriteString(this.name)
		return packet
	}
}
